package com.alpha;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.*;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;

public class CollectFDADrugsWebClient {
	public static void main(String args[]) throws IOException {

		
		String url = ("http://www.accessdata.fda.gov/scripts/cder/drugsatfda/index.cfm?fuseaction=Search.Search_Drug_Name");
		
		String  url2 = "http://www.accessdata.fda.gov/scripts/cder/drugsatfda/index.cfm?fuseaction=Search.Overview&DrugName=CABERGOLINE";

        System.out.println("AUTHORIZING: " + url);

        WebClient webClient = new WebClient();
        webClient.setJavaScriptEnabled(true);
        webClient.setRedirectEnabled(true);
        webClient.setThrowExceptionOnFailingStatusCode(false);
        webClient.setThrowExceptionOnScriptError(false);
        
        HtmlPage page = (HtmlPage)webClient.getPage(url);
        HtmlPage page2 = (HtmlPage)webClient.getPage(url2 );
        System.out.println(page2.asText());
 		
		
	}
}
